﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Import Namespace="MensUnoShop.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Coupon
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<style>
    table#coupon td{border:1px solid #ccc;}
</style>
<%var couponlist = ViewData["couponlist"] as List<V_CouponList>; %>
<div id="main-content" class="hastable">
    <div class="title title-spacing">
	    <h2>優惠券折扣設定</h2>
    </div>
    <form action="" method="post">
        設定優惠券：<br/>
        活動名稱：<input type="text" name="title" size="25" />，<input type="text" name="amount" size="5" />組，<input type="text" name="price" size="5" />元 <input type="submit" value="新增" />
    </form>
<br/>
<select id="couponlist" style="margin-bottom:10px;" onchange="chgList();"><option>請選擇</option></select>
<table id="coupon" style="width:700px;">
    <thead>
        <tr>
            <td>活動名稱</td>
            <td>序號</td>
            <td>金額</td>
            <td>是否領取</td>
            <td>是否使用</td>
        </tr>
    </thead>
    <tbody>
<%foreach (var c in couponlist)
  { %>
<tr><td class="stitle"><%:c.SCtitle %></td><td><%:c.SCticket %></td><td><%:c.SCprice %></td><td><%:c.SCislog?"是":"否" %></td><td><%:c.MCisused.HasValue?c.MCisused.Value?"是":"否":"否" %></td></tr>
<%} %>
    </tbody>
</table>
</div>
<script type="text/javascript">
    var clist = [];
    $(".stitle").each(function () {
        if ($.inArray($(this).html(), clist) == -1) {
            clist.push($(this).html());
        }
    });
    $(clist).each(function () { $("#couponlist").append('<option>' + this + '</option>'); });
    $("#coupon tbody tr").hide();

    function chgList() {
        $("#coupon tbody tr").hide();
        $("#coupon .stitle").each(function () {
            if ($(this).html() == $("#couponlist").val())
                $(this).parent().show();
        });
    }
</script>
</asp:Content>
